import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:grocery_app_demo/api/entity/dict.dart';
import 'package:grocery_app_demo/pages/purchase_main/purchase_create/goods_code_info.dart';

part 'goods_info.g.dart';

@CopyWith()
class GoodsInfo {
  final String goodsName;
  final String goodsCode;
  final Unit goodsUnit;
  final double standardWeight;
  final List<GoodsCodeInfo> goodsCodeInfoList;
  final double price;
  final double serviceCost;
  final double totalCount;
  final double totalWeight;
  final bool expand;

  GoodsInfo({
    required this.goodsName,
    required this.goodsCode,
    required this.goodsUnit,
    required this.standardWeight,
    required this.goodsCodeInfoList,
    required this.price,
    required this.serviceCost,
    required this.totalCount,
    required this.totalWeight,
    required this.expand,
  });

  String purchaseCost() {
    double totalCost = totalCount * price;
    return totalCost.toStringAsFixed(2);
  }

  String totalCost() {
    double totalCost = totalCount * price + serviceCost;
    return totalCost.toStringAsFixed(2);
  }
}
